(function($) {
	/*PLUGIN DE REDIMENSIONAMENTO DO MAPA PRA ACOMPANHAR LARGURA*/
	jQuery.fn.getHeight = function() {
		
		var mapWidth = $(this).width();
		var mapHeight = (mapWidth *9)/16;
		$("#map").height(mapHeight);

		$(window).resize( function() {
			
			var mapWidth = $("#map").width();
			var mapHeight = (mapWidth *9)/16;

			$("#map").height(mapHeight);
		});
	};
	
	jQuery.fn.getActualLocation = function() {
		var initialLocation;		
		var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
		var browserSupportFlag =  new Boolean();
		var map;
		var infowindow = new google.maps.InfoWindow();
		
		initializeLocation();
		
		function initializeLocation() {
		  var myOptions = {
		    zoom: 17,
		    mapTypeId: google.maps.MapTypeId.ROADMAP
		  };
		  map = new google.maps.Map(document.getElementById("map"), myOptions);
		  
		  // Try W3C Geolocation method (Preferred)
		  if(navigator.geolocation) {
		    browserSupportFlag = true;
		    navigator.geolocation.getCurrentPosition(function(position) {
		      initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
		      map.setCenter(initialLocation);		      
		    }, function() {
		      handleNoGeolocation(browserSupportFlag);
		    });
		  } else if (google.gears) {
		    // Try Google Gears Geolocation
		    browserSupportFlag = true;
		    var geo = google.gears.factory.create('beta.geolocation');
		    geo.getCurrentPosition(function(position) {
		      initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
		      map.setCenter(initialLocation);
		    }, function() {
		      handleNoGeolocation(browserSupportFlag);
		    });
		  } else {
		    // Browser doesn't support Geolocation
		    browserSupportFlag = false;
		    handleNoGeolocation(browserSupportFlag);
		  }
		}
		
		function handleNoGeolocation(errorFlag) {
		  if (errorFlag == true) {
		    initialLocation = newyork;
		    contentString = "Error: The Geolocation service failed.";
		  } else {
		    initialLocation = siberia;
		    contentString = "Error: Your browser doesn't support geolocation. Are you in Siberia?";
		  }
		  map.setCenter(initialLocation);
		  infowindow.setContent(contentString);
		  infowindow.setPosition(initialLocation);
		  infowindow.open(map);
		}
		
	};
	jQuery.fn.createMap = function(settings) {		
		var latlng = new google.maps.LatLng(settings.lat, settings.lng);
		
		var myOptions = {
		  zoom: 17,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map"),myOptions);

		var infowindow = new google.maps.InfoWindow();
		
	};
	
	
	
})(jQuery)